package com.huey.utils.thread;


import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author xubo
 */
public class ThreadPoolUtils {

    private static final ExecutorService FIX_THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(2, 4, 60, TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(1000),
            new ThreadFactoryBuilder().setDaemon(true).setNameFormat("executor-%d").build());

    /**
     * 获取线程池   cpu core * （1+avg等待/avg工作）
     * @return
     */
    public static ExecutorService getFixThreadPoolExecutor() {
        return FIX_THREAD_POOL_EXECUTOR;
    }


}
